//
//  MLZWebViewController.m
//  MotherLover
//
//  Created by lanou on 16/1/7.
//  Copyright © 2016年 zj. All rights reserved.
//

#import "MLZWebViewController.h"
#import "zJRequestManager.h"
@interface MLZWebViewController ()<UIWebViewDelegate>
@property (nonatomic, strong)UIWebView *webview;
@end

@implementation MLZWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    NSLog(@"%@",self.webUrl);
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    UIImageView *backImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 35, 20, 20)];
    backImageView.image = [UIImage imageNamed:@"fanhui"];
    [self.view addSubview:backImageView];
    
    
    //返回按钮
    UIButton *leftButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    leftButton.frame = CGRectMake(30, 30, 100, 30);
    [leftButton addTarget:self action:@selector(leftButtonAction:) forControlEvents:(UIControlEventTouchUpInside)];
    leftButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    leftButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    [leftButton setTitle:@"返回" forState:(UIControlStateNormal)];
    [leftButton setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    [self.view addSubview:leftButton];
    
    
    
    
    [self addWebView];
    self.tabBarController.tabBar.hidden= YES;
}
- (void)addWebView{
    
       
    _webview = [[UIWebView alloc]initWithFrame:CGRectMake(0, 64, KW, KH-64)];
    
    
    // webview 自适应屏幕的大小
    _webview.scalesPageToFit = YES;
    _webview.delegate =self;
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.webUrl]];
    [_webview loadRequest:request];
    [self.view addSubview:_webview];
        
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{

//    NSLog(@"ssss");
//    
//    if (navigationType == UIWebViewNavigationTypeLinkClicked)
//    {
//        NSURL *url = [request URL];
//        if([[UIApplication sharedApplication]canOpenURL:url])
//        {
//            [[UIApplication sharedApplication]openURL:url];
//        }
//        return NO;
//    }
//    return YES;
//}


return YES;
}

- (void)leftButtonAction:(UIButton *)leftButton
{
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
